<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<META content=IE=EmulateIE7 http-equiv=X-UA-Compatible>
<TITLE>博士生选房系统</TITLE>
<link href="css/css.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="css/calendar/iframe.css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/calendar/calendar.css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/calendar/dashboard.css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/calendar/i-heart-ny.css" media="screen" />
<script type="text/javascript" src="js/jquery.js"></script>
<!-- 注意jquery和mootools的命名空间在chrome和opera下有冲突，所以导致jquery无法用$选择器
将jquery提到最前解决问题，也可自行更改命名空间。 -->
<script type="text/javascript" src="js/calendar/mootools.js"></script>
<script type="text/javascript" src="js/calendar/calendar.rc4.js"></script>
<script type="text/javascript" src="js/min_contentslider.js"></script>
<script type="text/javascript" src="js/jquery.scrollFollow.js"></script>
<script type="text/javascript" src="js/jquery.query.js"></script>
<script type="text/javascript" src="js/jquery.dialog.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	var f = $.query.get("f");
	if(f==null||f==""){
		location.href="B04_control.html?f=1";
		return;
	}	
	$("#navigate_bar a:eq("+(f-1)+")").css({
		"background-color":"green",
		"color":"cyan"
	});
	$( '#flowDiv' ).scrollFollow(); 
	$.post("AjaxAction!getTimeRange.action",{
		department:"B04"
	},function(data){
		if(data[0].result=="success"){
			$('#start_time').html(data[1].opentime+" 00:00:00");
			$('#end_time').html(data[1].closetime+" 00:00:00");
		}
	},"json");
});
function setRoom(room, operation){
	var dialogHtml="<div style='width:300px; text-align:center'>";
	dialogHtml += "<p><span>房间:"+room+"</span>&nbsp;&nbsp;</p>";
	dialogHtml += "<p><span>床位数:</span><input type='radio' value='1' checked id='total' name='total'/>1";
	dialogHtml += "<input type='radio' value='2' checked id='total' name='total'/>2";
	dialogHtml += "<input type='radio' value='3' checked id='total' name='total'/>3";
	dialogHtml += "<input type='radio' value='4' checked id='total' name='total'/>4</p>";
	dialogHtml += "<p><span>开放状态:</span><input type='radio' value='1' checked id='state' name='state'/>开放";
	dialogHtml += "<input type='radio' value='0' id='state' name='state'/>关闭</p>";
	dialogHtml += "<p><span>房间类型:</span><input type='radio' value='0' checked id='sex' name='sex'/>男生";
	dialogHtml += "<input type='radio' value='1' id='sex' name='sex'/>女生</p>";
	dialogHtml += "<p><button id='okBt'>确定</button>&nbsp;&nbsp;<button id='cancelBt'>取消</button></p>";
	dialogHtml += "</div>";
	$.dialog.open(dialogHtml, function(){
		if($('#total').val()==""){
			alert('床位数不能为空');
			$('#total').focus();
			return false;
		}
		//room = id.substring(0,5)+$.query.get("f")+id.substring(6);
		$.post("AjaxAction!setRoomInfo.action",{
			room : room,
			total : $('#total:checked').val(),
			state : $('#state:checked').val(),
			sex : $('#sex:checked').val(),
			floor : $.query.get("f"),
			operation : operation
		},function(data){
			if (data[0].result == "logout") {
				alert("对不起，登陆超时，请重新登录！");
				parent.window.location.href = "login.html";
				return false;
			} else if (data[0].result == "error") {
				alert("错误！请与管理员联系");
			} else if (data[0].result == "success") {
				alert("设置成功！");
				$(window.frames["rooms"].document).find('#'+room).click();
				//$(window.frames["rooms"].document).showRoom(document.getElementById(id),1);
			} else if (data[0].result == "failed") {
				alert("设置失败！");
			} else if (data[0].result == "permission denied") {
				alert("对不起，您没有权限修改该房间的状态！");
			} else {
				alert("错误，可能是网络不通，请稍后重试，如果问题一直存在，请与管理员联系！");
			}
			$.dialog.close();
		},"json");
	},"body");
}

function setTime(){
	var dialogHtml="<div style='width:280px; text-align:center'>";
	dialogHtml += "<div id='time_form'><fieldset><legend>A10公寓选房时间设定</legend>";
	dialogHtml += "<label for='opentime'>开放时间</label><input type='text' id='opentime' name='opentime'/><br/><br/>";
	dialogHtml += "<label for='closetime'>关闭时间</label><input type='text' id='closetime' name='closetime'/><br/><br/>";
	dialogHtml += "<button id='okBt'>确定</button>&nbsp;&nbsp;<button id='cancelBt'>取消</button>";
	dialogHtml += "</fieldset></div>";
	dialogHtml += "</div>";
	$.dialog.open(dialogHtml,function(){
		var opentime = $('#opentime').val();
		var closetime = $('#closetime').val();
		if(opentime=="" || closetime==""){
			alert("请选择时间！");
		}else{
			$.post("AjaxAction!setTimeRange.action",{
				department : "B04",
				opentime : opentime,
				closetime : closetime
			},function(data){
				if (data[0].result == "logout") {
					alert("对不起，登陆超时，请重新登录！");
					parent.window.location.href = "login.html";
					return false;
				} else if (data[0].result == "error") {
					alert("错误！请与管理员联系");
				} else if (data[0].result == "success") {
					alert("设置成功！");
					$('#start_time').html(opentime+" 00:00:00");
					$('#end_time').html(closetime+" 00:00:00");
				} else if (data[0].result == "failed") {
					alert("设置失败！");
				} else if (data[0].result == "permission denied") {
					alert("对不起，您没有权限修改该公寓的状态！");
				} else {
					alert("错误，可能是网络不通，请稍后重试，如果问题一直存在，请与管理员联系！");
				}
				$.dialog.close();
			},"json");	
		}
	},"body");
	var myCal1 = new Calendar({ opentime: 'Y-m-d' }, { classes: ['dashboard'], direction: 1, tweak: {x: 3, y: -3} });
	var myCal2 = new Calendar({ closetime: 'Y-m-d' }, { classes: ['dashboard'], direction: 1, tweak: {x: 3, y: -3} });
}
</script>
</HEAD>
<BODY>
<div id="flowDiv">
		<div>
			<label>开始时间：</label><label id="start_time">--</label> <br /> <label>结束时间：</label><label
				id="end_time">--</label> <br />
			<button onclick="setTime();">选房时间设置</button>
		</div>
		<div id="colorInfo" style="margin-top: 10px;">
			<div>
				<span style="color: red">房间颜色提示：</span>
			</div>
			<div id="boyRoomInfo" style="position: relative">
				<div
					style="width: 40px; height: 20px; background-color: blue; opacity: 0.6">
				</div>
				<div style="position: absolute; top: 0px; left: 60px">
					<span style="color: blue;">男生房间</span>
				</div>
			</div>
			<div id="girlRoomInfo" style="position: relative">
				<div
					style="width: 40px; height: 20px; background-color: red; opacity: 0.6">
				</div>
				<div style="position: absolute; top: 0px; left: 60px">
					<span style="color: red;">女生房间</span>
				</div>
			</div>
			<div id="closedRoomInfo" style="position: relative">
				<div
					style="width: 40px; height: 20px; background-color: black; opacity: 0.6">
				</div>
				<div style="position: absolute; top: 0px; left: 60px">
					<span style="color: black;">未开放房间</span>
				</div>
			</div>
		</div>
	</div>

<div id="navigate_bar">
	<a href="B04_control.html?f=1">第 1   层</a><br/><br/>
    <a href="B04_control.html?f=2">第 2 层</a><br/><br/>
    <a href="B04_control.html?f=3">第 3 层</a><br/><br/>
    <a href="B04_control.html?f=4">第 4 层</a><br/><br/>
    <a href="B04_control.html?f=5">第 5 层</a><br/><br/>
    <a href="B04_control.html?f=6">第 6 层</a><br/><br/>   
</div>
<div id="room">
<!--left:355px total1205 -->
<iframe src="B04_manage.html" id="rooms" name="rooms" width="850px" height="545px" scrolling="no" frameBorder="0"></iframe>
</div>
<div id="bed" style="visibility:hidden"></div>
<div id="char"></div>
<div id="title">B04公寓选房</div>

</BODY>
</HTML>
